<template>
	<div class="box">
		<!--v-if="(bannerAnimation === 0 && env == 'production')|| (bannerAnimation === 0 && env == 'edit' && dataList.length>0)"-->
		<HomeCarousel v-if="(bannerAnimation === 0 && env == 'production')|| (bannerAnimation === 0 && env == 'edit' && dataList.length>0)" :swipimgage="swipimgage" :swipimgagewidth="screenWidth" :swipimgageheight="screenHeight"></HomeCarousel>
		<HomeCarouselnew v-if="(bannerAnimation === 1 && env == 'production')|| (bannerAnimation === 1 && env == 'edit' && dataList.length>0)" :swipimgage="swipimgage" :swipimgagewidth="screenWidth" :swipimgageheight="screenHeight"></HomeCarouselnew>
	    <div v-if="dataList.length==0 && env == 'edit' " style="height: 2.5rem;line-height: 2.5rem;">暂无数据</div>
	</div>
</template>

<script>
	import { getPageNameOrVirtualPageName } from "../../utils/getPageName";
	import HomeCarousel from "./HomeCarousel1";
	import HomeCarouselnew from "./HomeCarousel2";
	import { mapGetters } from "vuex";
	import { getPageTree, initDomTree } from "../../utils/getPageTree";
	import axios from "axios";
	export default {
		props: {
			dataList: {
				type: Array,
				default: () => []
			},
			config: {
				type: Object,
				default: ()=>{}
			},
			part:{
				type:Number,
				default:1
			}
		},
		data() {
			return {
				msg: '这是首页',
				page: "home",
				componentName: "HomeCarousel",
				componentName: "HomeCarouselnew",
				swipimgage: [],
			}
		},
		computed: {
			...mapGetters([
				"getDomTree"
			]),
			pageTree() {
				return getPageTree(this, this.page);
			},
			screenWidth() {
				if(window.environment === "production") {
					return window.innerWidth;
				} else {
					return 375;
				}
			},
			screenHeight() {
				if(window.environment === "production") {
					return window.innerWidth * 0.454;
				} else {
					return 170;
				}
			},
			pageName() {
				return getPageNameOrVirtualPageName();
			},
			bannerAnimation() {
				if(this.config.id) {
					return parseInt(this.getCurrentVDONew(this.config.id, this.part).config.bannerAnimation);
				}
			},
			env() {
				return window.environment; // 获取是否是编辑状态
			},
		},
		components: {
			HomeCarousel,
			HomeCarouselnew
		},
		methods: {
			queryBanner() {
				this.swipimgage = []
				for(var i = 0; i < this.dataList.length; i++) {
					if(this.dataList[i].status == 1) {
						this.swipimgage.push(this.dataList[i])
					}
				}
			}
		},
		watch: {
			dataList() {
				this.queryBanner()
			},
		},
		created() {},
		mounted() {
			this.queryBanner()
		},
		
	}
</script>

<style scoped>
</style>